<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<%@ page import="java.io.*"%>
<html>
<jsp:useBean id="uploadFileForm1" scope="session" class="mypack.form.UploadFileResultForm"/>

<head>
<meta http-equiv="content-Type" contentType="text/html; charset=utf-8">
<%request.setCharacterEncoding("ISO-8859-1"); %>

<title>上传</title>
 <!-- 新 Bootstrap 核心 CSS 文件 -->
			<link rel="stylesheet" href="static/css/bootstrap.min.css">
            <!-- 可选的Bootstrap主题文件（一般不用引入） -->
			<link rel="stylesheet" href="static/css/bootstrap-theme.min.css">

            <!-- jQuery文件。务必在bootstrap.min.js 之前引入 -->
			<script src="http://cdn.bootcss.com/jquery/1.11.1/jquery.min.js"></script>

			<!-- 最新的 Bootstrap 核心 JavaScript 文件 -->
			<script src="static/js/bootstrap.min.js"></script>
            <link href="static/css/login.css" rel="stylesheet" type="text/css" />
            <link href="static/css/homepage.css" rel="stylesheet" type="text/css" />
</head>
<body style="background-image: url(../static/images/app.jpg);">
<nav class="navbar navbar-default navbar-fixed-top" role="navigation">
            <div id = "banner">
                <ul class="nav nav-tabs" role="tablist">
                    <li role="presentation" class="active" style="color:#44484F;"><a href="http://localhost:8080/softwaretest/index.jsp">Homepage</a></li>
                    <li role="presentation" ><a href="#" style="color:#44484F;">Data flow</a></li>
                    <li role="presentation"><a href="#" style="color:#44484F;">Control flow</a></li>
                    <li role="presentation"><a href="#" style="color:#44484F;">Show in Finder</a></li>
					<li role="presentation"><a href="#" style="color:#44484F;">History</a></li>
                </ul>
            </div> 
            </nav>
            <br>
             <br>
              <br>
               <br>
               <div id = "input1" style="height:440px;width:450px;margin-left:400px;">
<div id = 'inner1' style="height:320px; width:480px;">
<div>
<% uploadFileForm1.setParameters(request, response); %>
<%
InputStream in = null;
FileOutputStream o = null;

 try{
  String temp=(String)request.getSession().getAttribute("check_code");//获得sessionId
  //上传文件的存储路径
  String test = uploadFileForm1.getHname();
  String filename = "F:\\学习\\大三上\\web\\final\\学生作业\\"+"作业_" +"第"+test+"次作业"+ "_"+ temp + ".txt";
  
  //out.println("   这是测试结果: "+ test + "    这是测试结果");
  String fn=new String(filename);

  File f1=new File(fn);    
   f1.createNewFile();
  o=new FileOutputStream(f1);                                 //文件输出流指向上传文件所在路径
  
  in = request.getInputStream();                                         //从客户端获得文件输入流
  
  
  InputStreamReader reader = new InputStreamReader (in); 
  
  BufferedReader bufferedReader = new BufferedReader(reader);
  String linetxt;
  for(int i = 0;i < 3;i++){
	  linetxt = bufferedReader.readLine();
	  
  }
  while(((linetxt = bufferedReader.readLine())!= null) && (linetxt.indexOf("------WebKitFormBoundar") == -1) ){
	 
      		linetxt += "\r\n";     
	 
	  o.write(linetxt.getBytes());
          // out.println(linetxt + " \r\n ");
           
  }
  
 
 
  out.println( " <p>Submit successfully!</p> ");
  
  
  o.close();
  in.close();                                                                                                           //关闭输入流和文件输出流
  out.println("<a class='btn btn-primary btn-lg' role='button' href = 'http://localhost:8080/softwaretest' >Back to homepage</a><br><br>");
  %>
  
<FORM action=chart.html method="POST">
	   
	     <input type="hidden" size="0" name="hname" value=<%=test%>>
	     <input type="hidden" size="0" name="sname" value=<%=request.getSession().getAttribute("check_code")%>>
	    
		<input class="btn btn-primary btn-lg" role="button" type=submit value="Check submit info">

</form>
<!-- <script language="javascript">alert("文件上传成功！");</script> -->
<%
 }catch (Exception e) {
	 out.println("！！~~这是错误原因：  "+e.getMessage());
	  
 } finally {
 }
%>

</div>
</div>
</div>
       <div id="leftContainer"  margin-top: 30px;> 
                    <p class = "copyright">Copyright © Sidan Yao. All rights reserved. </p>
					<p class = "copyrightE">     Email:1013748619@qq.com</p>
	   </div>
	   
	   </body>
	   </html>